<!DOCTYPE html>
<html lang="en">
  <head>
    <meta charset="UTF-8" />
    <meta http-equiv="X-UA-Compatible" content="IE=edge" />
    <meta name="viewport" content="width=device-width, initial-scale=1.0" />
    <title>Document</title>
  </head>
  <body>
    <div id="app">
      <!-- lazy修饰符 -->
      <!-- 需要失去焦点才会改变,input事件换成了change事件 -->
      <input type="text" v-model.lazy="val" />
      <span>{{ val }}</span>

      <hr />

      <!-- number修饰符 -->
      <!-- 将绑定的数据去尝试改成数字类型 -->
      <input type="text" v-model.number="num" />
      <span>{{num}}</span>
      <button @click="fn">btn</button>

      <hr />

      <!-- trim修饰符 -->
      <!-- trim用于去除首尾空格 -->
      <input type="text" v-model.trim="str" />
      <p>{{str}}</p>
      <button @click="fn2">btn</button>
    </div>

    <script src="./Vue3.js"></script>
    <script>
      const { createApp } = Vue;

      createApp({
        data() {
          return {
            val: "a",
            num: 123,
            str: "",
          };
        },
        methods: {
          fn() {
            console.log(typeof this.num);
          },
          fn2() {
            console.log(this.str);
          },
        },
      }).mount("#app");
    </script>
  </body>
</html>
